<?php

namespace App\Console\Commands;

use App\Models\Ad;
use App\Models\AdminBill;
use App\Models\AdminProfitReport;
use App\Models\AdminWallet;
use App\Models\AdminWithdrawOrder;
use App\Models\AgentStatistical;
use App\Models\Bill;
use App\Models\Device;
use App\Models\DeviceBill;
use App\Models\DeviceCoverLog;
use App\Models\DeviceLog;
use App\Models\DeviceOrder;
use App\Models\DeviceRepairLog;
use App\Models\DistributorStatistical;
use App\Models\FactoryDevice;
use App\Models\FactoryStatistical;
use App\Models\GlobalBill;
use App\Models\GlobalStatistical;
use App\Models\Group;
use App\Models\GroupBill;
use App\Models\GroupInspectionLog;
use App\Models\GroupMember;
use App\Models\GroupPolicy;
use App\Models\GroupPolicyRule;
use App\Models\MarketingPolicy;
use App\Models\MarketingPolicyRule;
use App\Models\MerchantStatistical;
use App\Models\Order;
use App\Models\PriceSpecification;
use App\Models\RepairerDeviceGroup;
use App\Models\RepairerStatistical;
use App\Models\Role;
use App\Models\SmsCode;
use App\Models\StaffStatistical;
use App\Models\User;
use App\Models\Wallet;
use App\Models\Wechat;
use App\Models\WithdrawOrder;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class ClearData extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'clear:data';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '清空业务数据';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Wechat::truncate();
        Ad::truncate();
        AdminBill::truncate();
        AdminProfitReport::truncate();
        AdminWallet::truncate();
        AdminWithdrawOrder::truncate();
        AgentStatistical::truncate();
        Bill::truncate();
        Device::truncate();
        DeviceBill::truncate();
        DeviceCoverLog::truncate();
        DeviceLog::truncate();
        DeviceOrder::truncate();
        DeviceRepairLog::truncate();
        DistributorStatistical::truncate();
        FactoryDevice::truncate();
        FactoryStatistical::truncate();
        GlobalBill::truncate();
        GlobalStatistical::truncate();
        Group::truncate();
        GroupBill::truncate();
        GroupInspectionLog::truncate();
        GroupMember::truncate();
        GroupPolicy::truncate();
        GroupPolicyRule::truncate();
        MarketingPolicy::truncate();
        MarketingPolicyRule::truncate();
        MerchantStatistical::truncate();
        Order::truncate();
        PriceSpecification::truncate();
        RepairerDeviceGroup::truncate();
        RepairerStatistical::truncate();
        Role::truncate();
        SmsCode::truncate();
        StaffStatistical::truncate();
        User::truncate();
        Wallet::truncate();
        Wechat::truncate();
        WithdrawOrder::truncate();
        DB::select('SET FOREIGN_KEY_CHECKS=?', [0]);
        DB::table('oauth_refresh_tokens')->truncate();
        DB::table('oauth_access_tokens')->truncate();
        DB::table('oauth_access_token_providers')->truncate();
        DB::select('SET FOREIGN_KEY_CHECKS=?', [1]);
    }
}
